import typescript from "rollup-plugin-typescript2";
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import json from "@rollup/plugin-json";

/**
 * 渲染多个输出的类
 */
class RollupOutputs{
  static configs = []
  /**
   * 渲染一个输出
   * @param {String}} inputPath 输入路径
   * @param {String} outputPath 输出路径
   */
  static add(inputPath,outputPath){
    this.configs.push({
      input: inputPath,
      output: {
        file: outputPath,
        sourcemap: true,
        format: "cjs",
      },
      plugins: [
        typescript(),
        json(),
        commonjs(),
        nodeResolve()
      ],
    })
  }
  /**
   * 获取渲染配置数组
   * @returns 渲染的配置数组
   */
  static getConfigs(){
    return this.configs;
  }
}

// 添加渲染
RollupOutputs.add(
  "./src/index.ts",
  "./dist/build.js"
);
export default RollupOutputs.getConfigs();